package com.topscomm.gpm.script;

import com.topscomm.cbo.pojo.CboApprovalNodeInsEntity;
import com.topscomm.pub.util.ConvertUtil;
import com.topscomm.pub.util.SpringUtil;
import com.topscomm.gpm.GpmScript;
import com.topscomm.gpm.pojo.GpmProjectAppointmentEntity;
import com.topscomm.gpm.service.impl.GpmProjectAppointmentService;
import com.topscomm.tap.ITapService;
import com.topscomm.tap.TapEntity;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Description TODO
 * @Classname SdProjectHistoryScript
 * @Date 2021/12/13
 * @Created by wxh
 */
public class GpmAppointmentChangeScript extends GpmScript {

	@Transactional(rollbackFor = Exception.class)
	public void saveBaseChangeLog(ITapService service, TapEntity entity) throws Exception {
		// 审批节点实例
		CboApprovalNodeInsEntity nodeins = (CboApprovalNodeInsEntity) entity;
		String sourceid = ConvertUtil.convertToString(nodeins.getSourceid());
		GpmProjectAppointmentService gpmProjectAppointmentService = (GpmProjectAppointmentService) SpringUtil.getBean("gpmProjectAppointmentService");
		// 获取任命书信息
		GpmProjectAppointmentEntity gpmProjectAppointmentEntity = gpmProjectAppointmentService.queryById(sourceid);
		if (gpmProjectAppointmentEntity.getVersion() > 1) {
			gpmProjectAppointmentService.changeEditNodePass(sourceid);
		}
	}
}
